﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.ServiceModel;

namespace WcfService
{
    [ServiceContract(Name = "IService1",SessionMode = SessionMode.Allowed)]
    public interface IService1
    {
        [OperationContract]
        string GetData();

        [OperationContract]
        bool Loguj(string username, string password, string[] konfiguratorFile);

        [OperationContract]
        TablicaDanych GetListDocuments();

        [OperationContract]
        TablicaDanych GetMagazynier();
    }

    [Serializable]
    [CollectionDataContract]
    public class ListaDanych
    {
        List<string> lista;
        [DataMember]
        public List<string> Lista
        {
            get { return lista; }
            set { lista = value; }
        }
        public ListaDanych()
        {
            lista = new List<string>();
        }
    }

    [DataContract]
    public class TablicaDanych :IEnumerable<ComboBoxItem>
    {
        List<ComboBoxItem> tablica = null;
        [DataMember]
        public List<ComboBoxItem> Tablica
        {
            get { return this.tablica; }
            set { this.tablica = value; }
        }
        public TablicaDanych()
        {
            this.InitializeComponent();
        }
        private void InitializeComponent()
        {
            this.Tablica = new List<ComboBoxItem>();
        }

        [OnDeserializing]
        public void OnDeserializing(StreamingContext ctx)
        {
            this.InitializeComponent();
        }

        public IEnumerator<ComboBoxItem> GetEnumerator()
        {
            return this.Tablica.GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return this.Tablica.GetEnumerator();
        }
    }

    /// <summary>
    /// Struktura do przechowywania zawartości comboboxów zwracanych z metody WyborModeliFillCheckboxes
    /// </summary>
    public class ComboBoxItem
    {
        private string key = string.Empty;
        private string value = string.Empty;

        public ComboBoxItem()
        {
            this.InitializeComponent();
        }
        public ComboBoxItem(string key, string value)
        {
            this.Key = key;
            this.Value = value;
        }
        public string Key
        {
            set { this.key = value; }
            get { return key; }
        }
        public string Value
        {
            set { this.value = value; }
            get { return value; }
        }
        private void InitializeComponent()
        {
            this.Key = string.Empty;
            this.Value = string.Empty;
        }
    }
}
